package com.ws.hzuoj.admin.system.dictionary.web;

import cn.hutool.core.util.StrUtil;
import com.ws.common.easyui.util.Page;
import com.ws.common.easyui.util.PageUtils;
import com.ws.hzuoj.admin.system.dictionary.entity.DictionaryType;
import com.ws.hzuoj.admin.system.dictionary.service.IDictionaryTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.util.List;

@RequestMapping("/admin/system/dictionary/type")
@Controller
public class DictionaryTypeWeb {


    @Autowired
    IDictionaryTypeService dictionaryTypeService;

    @RequestMapping("{type}")
    public String list(@PathVariable String type){
        return  null;
    }

    @RequestMapping("/listData")
    @ResponseBody
    public Object listData(DictionaryType dictionaryType,Page page){
        List<DictionaryType> dictionaryTypes=dictionaryTypeService.list(dictionaryType,page);
        return PageUtils.getEasyUiList(dictionaryTypes);
     }

    @RequestMapping("read")
    @ResponseBody
    public Object read(DictionaryType dictionaryType){
        if(StrUtil.isNotEmpty(dictionaryType.getId())){
            dictionaryType= dictionaryTypeService.read(dictionaryType.getId());
        }
        return  dictionaryType;
    }

    @RequestMapping("/save")
    @ResponseBody
    public Object save(DictionaryType dictionaryType){
        Integer count=dictionaryTypeService.save(dictionaryType);
        return  count;
     }

    @RequestMapping("/delete")
    @ResponseBody
    public Integer delete(String id){
        return  dictionaryTypeService.delete(id);
    }

    @RequestMapping("/insert")
    @ResponseBody
    public Object insert(DictionaryType dictionaryType){
        Integer count=dictionaryTypeService.insert(dictionaryType);
        return  count;
    }

    @RequestMapping("/insertSelective")
    @ResponseBody
    public Object insertSelective(DictionaryType dictionaryType){
        return dictionaryTypeService.insertSelective(dictionaryType);
    }

    @RequestMapping("/update")
    @ResponseBody
    public Object update(DictionaryType dictionaryType){
        return dictionaryTypeService.update(dictionaryType);
    }

    @RequestMapping("/listAll")
    @ResponseBody
    public Object listByMap(){
        return  dictionaryTypeService.listAll();
    }
}
